<!DOCTYPE html>
<%@page import="com.tdcy.framework.util.SessionUtils"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>配置管理中心</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<jsp:include page="../../hcommon.jsp"></jsp:include>
</head>
<!-- 自定义js -->
<script type="text/javascript"> 
var data  = AppKit.getInvokeWindowData();
var operflag = data["operflag"];

    $(document).ready(function () {
    	 $.jgrid.defaults.width = 960;
		 $.jgrid.defaults.responsive = true;
		 $.jgrid.defaults.styleUI = 'Bootstrap';
		 $.jgrid.ajaxOptions.type = 'post';
    	 initmodelGridIdTable();
    });
    
    /**
    *初始化表单
    */
    function initmodelGridIdTable() {
    	var queryParams = {};
		var colModel=[];
        var colIdItem={label: '名称', name: 'nickname', align: 'left',width: 120,sortable:true, checkbox:true};
           colModel.push(colIdItem);
        var colDeploymentIdItem={label: '头像', name: 'headImgUrl', align: 'center',width: 60,sortable:true,formatter:imageFormatter};
           colModel.push(colDeploymentIdItem);
        var colNameItem={label: '性别', name: 'sex', align: 'center',width: 40,sortable:true,formatter:sexFormatter};
           colModel.push(colNameItem);
           var colNameItem={label: '省市', name: 'country', align: 'center',width: 120,sortable:true,formatter:ccFormatter};
           colModel.push(colNameItem);
           var colNameItem={label: '关注时间', name: 'subscribeTime', align: 'center',width: 120,sortable:true,formatter:ttFormatter};
           colModel.push(colNameItem);
		var settings={
            postData: queryParams,
            styleUI : 'Bootstrap',
		    mtype: "get",
		    url: "${path }/wxusertag/tagListUser?id="+data["id"],
		    prmNames:{//请求参数格式预处理
		          page:"page",
		          rows:"rows", 
		          sort:"sort",
		          order: "order"
		    },
		    datatype: "json",
            colModel:colModel,
		    pageable: false,
		    page: 1,
		    rowNum: '-1',
            multiSort: true,
		    sortable: true,
		    sortname: "id",
		    sortorder: "asc",
		    multiselect: false,
		    shrinkToFit: true,
		    height: 550,
		    shrinkToFit: true,
		    jsonReader: {//返回参数格式处理
		        root: "data"
		    },
		    rownumbers: false,
		    multikey: "true",
		    autowidth: true,
           };
           $("#modelGridIdGrid").jqGrid(settings);
       };
    	function operFormatter(value, options, row){
		    	 var href="";
		         href +="<a href=\"#\" class=\"btn btn-xs btn-primary\"  onclick=\"openAdd('"+row.openId+"')\">更新备注</a>&nbsp&nbsp";
			     href +="<a href=\"#\" class=\"btn btn-xs btn-primary\"  onclick=\"viewUserTag('"+row.openId+"')\">查看用户标签</a>&nbsp&nbsp";
	    	 return href;
		}

	function imageFormatter(value, options, row){
		    	 var href="";
		         href +="<img src="+value+" style='width:30px;heigth:30px;'></img>&nbsp&nbsp";
	    	 return href;
		}

	function sexFormatter(value, options, row){
		    	if("1" == value){
		    		return "男";
		    	}else{
		    		return  "女";
		    	}
		}


	function ccFormatter(value, options, row){
		    return value+" "+row["province"]+" "+row["city"];
		}
	
function ttFormatter(value, options, row){
	value=value*1000;  
	    var date =  new Date(value);
	    var y = 1900+date.getYear();
	    var m = "0"+(date.getMonth()+1);
	    var d = "0"+date.getDate();
	    return y+"-"+m.substring(m.length-2,m.length)+"-"+d.substring(d.length-2,d.length);
	}

  	
   	function batchRemove(id){
   		AppKit.showConfirmMessage(function(){
   			var url = '${path}/wxusertag/delUserTags/'+id;
   			AppKit.postJSON(url, null, function(json){
   				 AppKit.showTipMessage(json.msg, "提示", function(){
    				reloadTable();
    			 });
   			})
   		}, "确定要移除该记录?", "提示");
   	}
   	
   	function reloadTable(){
   		$("#modelGridIdGrid").trigger("reloadGrid"); //重新载入    
   	}
   	
   	function search(){
   		var queryParams =AppKit.getQueryParam("modelGridIdGridQueryForm","id,name,dbtype"); 
        //传入查询条件参数  
        $("#modelGridIdGrid").jqGrid('setGridParam',{  
            datatype:'json',  
            postData:queryParams, //发送数据  
            page:1  
        }).trigger("reloadGrid"); //重新载入    
   	}
   	
	function iChecks()
	{
		$(".i-checks").iCheck({
	           checkboxClass: 'icheckbox_square-green',
	           radioClass: 'iradio_square-green',
	       });
	}
   </script>

</head>
<body class="gray-bg skin-1">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
					    <div>
							
							<!-- 工具栏 -->
							<div class="row">
								<div class="col-sm-12">	
									<div class="pull-left">
									      <button class="btn btn-sm btn btn-sm btn-primary" onclick="batchRemove()"><i class="fa fa fa-plus"></i>批量移除</button>
									</div>
								</div>
							</div>
							<div class="jqGrid_wrapper uadmin-grid-margin" >
						        <table id="modelGridIdGrid">
						        </table>
						        <div id="pager_modelGridId"></div>
							</div>
						</div>
					</div>	
				</div>
			</div>
		</div>
	</div>
</body>
</html>

           